$(function() {
    $('#ajaxBtn').click(function(e) {
        e.preventDefault();
        let user = {
            "account": "admin",
            "password": "123456",
        }
        $.ajax({
            type: "post",
            url: "http://localhost:8080/springmvc-sample03/ajax",
            data: user,
            dataType: "json",
            xhrFields: {
                withCredentials: true
            },
            crossDomain: true,
            success: function(response) {
                window.console.log(response);
            },
            error: function(response) {
                window.console.log("服务器大大病了");
            }
        });
    });
    $('#ajaxJsonBtn').click(function(e) {
        e.preventDefault();
        let user = {
            "account": "admin",
            "password": "123456",
        }
        $.ajax({
            type: "post",
            url: "http://localhost:8080/springmvc-sample03/ajaxJson",
            contentType: 'application/json;charset=UTF-8',
            data: JSON.stringify(user),
            dataType: "json",
            xhrFields: {
                withCredentials: true
            },
            crossDomain: true,
            success: function(response) {
                window.console.log(response);
            },
            error: function(response) {
                window.console.log("服务器大大病了");
            }
        });
    });
});